"""
multiprocessing.Array创建共享数组
"""
import multiprocessing


def func(num):
    num[2] = 9999  #子进程改变数组，主进程跟着改变


if __name__ == "__main__":
    num = multiprocessing.Array("i", [1, 2, 3, 4, 5])  # i表示整形数值，主进程与子进程共享这个数组
    print('num 数组改变前：', num[:])

    p = multiprocessing.Process(target=func, args=(num, ))
    p.start()
    p.join()

    print('num 数组改变后：', num[:])
